/**
 * Copyright (c) 2016-present, ecidi.
 * All rights reserved.
 * 
 * This source code is licensed under the GPL-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk';
import platformReducer from './_platform/store/global';
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
import { containerReducers } from './Containers/reducers';
import { historyChangeReducer, historyChangeActionCreater } from './_platform/store/history'
// chrome redux-develop-tool
const composeEnhancers = composeWithDevTools({
});
// 初始化store数据对象
const initialState = window.___INITIAL_STATE__;
// 将store和history进行关联，支持history对象，方便修改url
const middleware = [thunk];
const enhancers = [];
const store = createStore(
	combineReducers({ platform: platformReducer, currentLocation: historyChangeReducer, ...containerReducers }),
	initialState,
	composeEnhancers(
		applyMiddleware(...middleware),
		...enhancers
	)
);
export const historyListener = (location) => {
	store.dispatch(historyChangeActionCreater(location));
}

export default store;



